using System;
using System.Runtime.InteropServices;
namespace Common.Environment
{
	public class WinInet
	{
		[Flags]
		private enum ConnectionState
		{
			InternetConnectionModem = 1,
			InternetConnectionLan = 2,
			InternetConnectionProxy = 4,
			InternetRasInstalled = 16,
			InternetConnectionOffline = 32,
			InternetConnectionConfigured = 64
		}
		[DllImport("wininet.dll", CharSet = CharSet.Auto)]
		private static extern bool InternetGetConnectedState(ref WinInet.ConnectionState lpdwFlags, int dwReserved);
		public static bool IsConnectedToInternet()
		{
			WinInet.ConnectionState connectionState = (WinInet.ConnectionState)0;
			bool flag;
			bool result;
			try
			{
				flag = WinInet.InternetGetConnectedState(ref connectionState, 0);
			}
			catch (Exception)
			{
				result = false;
				return result;
			}
			result = flag;
			return result;
		}
	}
}
